import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(),
    AutoImport({
    resolvers: [ElementPlusResolver()],
  }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  css: {
    preprocessorOptions: {
      scss: {
        // '@import "assets/scss/globalVar.scss";@import "assets/scss/globalMixin.scss";'
        additionalData: '@import "./src/assets/scss/globalVar.scss";@import "./src/assets/scss/globalMixin.scss";'
      }
    }
  },
  server:{
    proxy:{
      '/weatherInfo': {
        secure: false,
        target: 'https://restapi.amap.com/v3/weather/weatherInfo',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/weatherInfo/, '')
      },
      '/geo': {
        secure: false,
        target: 'https://restapi.amap.com/v3/geocode/geo',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/geo/,'')
      },
      '/regeo':{
        secure: false,
        target: 'https://restapi.amap.com/v3/geocode/regeo',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/regeo/,'')
      },
    }
  }
})
